package cn.zsxmlv.modules.sys.redis;

import cn.zsxmlv.common.utils.RedisKeys;
import cn.zsxmlv.common.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: zs
 * @description: 用户Redis
 * @date: 2019/1/25 15:42
 */
@Component
public class SysUserRedis {

    @Autowired
    private RedisUtils redisUtils;

    /**
     * 手动下线用户
     * @param userId 被踢下线的用户
     */
    public void offline(Integer userId) {
        String loginUserKey = RedisKeys.getLoginUserKey(userId);
        String token = redisUtils.get(loginUserKey);

        redisUtils.delete(token);
        redisUtils.delete(loginUserKey);
    }

}
